package com.qf.service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageInfo;
import com.qf.dto.PageQueryDTO;
import com.qf.ge.model.TUsers;
import com.qf.mapper.OneTestMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

import static com.github.pagehelper.page.PageMethod.startPage;

/**
 * @author ahuan
 * @classname OneTestServiceImpl
 * @description TODO
 * @date 2023年11月29日 13:19
 */
@Service
public class OneTestServiceImpl extends ServiceImpl<OneTestMapper, TUsers> implements OneTestService {

    @Autowired
    OneTestMapper oneTestMapper;


  /**
   * @description:
   * @param pageQueryDTO
   * @return com.baomidou.mybatisplus.core.metadata.IPage<com.qf.ge.model.TUsers>
   * @author: ahuana
   * @date: 2023/11/29 20:22
   */
    @Override
    public PageInfo<TUsers> listPage(PageQueryDTO pageQueryDTO) {
        if (pageQueryDTO.getPageNum()==null)pageQueryDTO.setPageNum(0);
        if (pageQueryDTO.getPageSize()==null)pageQueryDTO.setPageSize(10);
        int startRow= (pageQueryDTO.getPageNum()-1)* pageQueryDTO.getPageSize();
        //获取开启
        startPage(pageQueryDTO.getPageNum(), pageQueryDTO.getPageSize());
        if (pageQueryDTO.getTusers()==null)pageQueryDTO.setTusers(new TUsers());
        List<TUsers> usersList=oneTestMapper.listPages(startRow,pageQueryDTO.getPageSize(),
                pageQueryDTO.getTusers());

        PageInfo<TUsers> tUsersPageInfo = new PageInfo<>(usersList);
        return tUsersPageInfo;
    }
}